fix(swift-sdk): make Document transition contract/type pickers idb-drivable#3921
Conversation
…ivable
The Document state-transition builders (Purchase / Transfer / Update Price /
Create / Replace / Delete) selected their contract and document type with
SwiftUI Pickers that UI automation (idb) cannot drive, which blocked
automating DOC-07 and the other contract-scoped document builders.
TransitionDetailView hosts these inputs in a ScrollView/VStack, not a
Form/List. In that host:
- .accessibleInlinePicker renders as an opaque control idb sees only as a
"Slider" (option rows absent from the accessibility tree), and
- .accessibleFormPicker / .pickerStyle(.navigationLink) renders and pushes
its list but silently drops the selection binding (it only commits with a
List/Form ancestor).
Replace both pickers with an explicit NavigationLink to a small selection
List whose rows are Buttons that write the binding directly and dismiss().
Each row carries a stable accessibilityIdentifier
(transition.<input>.<picker>.row.<id>) so idb can tap a specific contract or
type reliably, and the selection commits in any host. contractPicker() is
shared by every document builder, so all of them become drivable.
Also guard TransitionDetailView's one-time form setup: pushing a picker list
re-fires .onAppear on pop-back, and re-running clearForm() there wiped the
in-progress form (including the just-picked contract). A didInitializeForm
flag runs clearForm()/pre-fill merge only on first appearance; a freshly
navigated builder is a new instance and still resets correctly.
Verified end-to-end on testnet via idb: the Purchase Document form drives
fully (contract "Contract with card", type "card", document id), selections
persist across pop-back, and the price auto-fetches (100000 credits).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesNavigation picker refactor and onAppear guard
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
✅ Review complete (commit 46f0acf) |
thepastaclaw
left a comment
There was a problem hiding this comment.
Code Review
Both agents and CodeRabbit converged on no in-scope findings. The PR is a focused SwiftExampleApp UI/testability fix that swaps inline Pickers for NavigationLink-pushed selection lists with stable per-row accessibility IDs, and guards TransitionDetailView's one-time form setup so popping the pushed picker doesn't wipe the in-progress form. The didInitializeForm guard is correctly scoped to the view-instance lifetime (transitionKey is a let, so a freshly-built builder is a new struct with a fresh @State). No consensus-critical surface area touched.
Issue being fixed or feature implemented
The SwiftExampleApp Document state-transition builders (Purchase / Transfer / Update Price / Create / Replace / Delete) select their data contract and document type through SwiftUI
Pickers that UI automation (idb) cannot drive. This blocked automating DOC-07 (Purchase Document) and every other contract-scoped document builder.TransitionDetailViewhosts these inputs in aScrollView { VStack }, not aForm/List. In that host:.accessibleInlinePickerrenders as an opaque control that idb sees only as aSlider— the option rows are absent from the accessibility tree (describe-allanddescribe-pointreturn nothing tappable)..accessibleFormPicker/.pickerStyle(.navigationLink)renders and pushes its list, but silently drops the selection binding — navigationLink only commits its selection when it has aList/Formancestor. (Verified on an iPhone 17 simulator: the row tap pops back but the checkmark stays on the previous value.)So neither shared picker style works in this host, which is why the builders couldn't be driven.
What was done?
Replaced the contract and document-type pickers with an explicit
NavigationLinkto a small selectionListwhose rows areButtons that write the binding directly anddismiss():ContractSelectionList/DocumentTypeSelectionListinTransitionInputView.swift.accessibilityIdentifier—transition.<input>.contractPicker.row.<idBase58>/transition.<input>.documentTypePicker.row.<name>— so idb can tap a specific contract/type by id, robustly across localization and layout changes.Form/Listdependency), and the trigger row shows the current selection.contractPicker()is shared by all six document builders, so all of them become drivable.Also guarded
TransitionDetailView's one-time form setup with adidInitializeFormflag: pushing a picker list re-fires.onAppearon pop-back, and re-runningclearForm()there wiped the in-progress form (including the just-picked contract). Setup now runs only on first appearance; a freshly navigated builder is a new view instance and still resets correctly.How Has This Been Tested?
Built the SwiftExampleApp for the simulator and drove DOC-07 end-to-end via idb on a booted iPhone 17 (testnet), using the existing fixture (contract
5jpKat9U82PGcfmeYm8QZZWX6q7zDo2C32PZMxHpbiGB, doc typecard, Knight cardCdg8JTz6Rbx6Hq8swZLkVCLML3acRTtsShwVfrUpG2mXpriced at 100000 credits, buyerqagaussqa≠ owner):Breaking Changes
None. UI/testability change in the example app only; no protocol or public-API changes.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
New Features